const Mock = require('mockjs');

// 模拟任务定义接口的请求体
const taskRequestBody = Mock.mock({
  "dataSetId": "@integer(1, 100)",
  "taskName": "@cword(2, 5)",
  "testType": "@integer(0, 2)",
  "errorStrategy": "@integer(0, 2)",
  "triggerRule": "@integer(0, 2)",
  "startTime": "@datetime",
  "endTime": "@datetime",
  "cron": "@string('number', 15)",
  "duration": "@integer(1, 100)",
  "endStrategy": "@integer(0, 2)",
  "deviceType": "@integer(0, 2)",
  "sendFlag": "@integer(0, 2)",
  "localLongitude": "@float(-180, 180, 2, 6)",
  "localLatitude": "@float(-90, 90, 2, 6)",
  "localAltitude": "@float(0, 10000, 2, 6)",
  "remoteLongitude": "@float(-180, 180, 2, 6)",
  "remoteLatitude": "@float(-90, 90, 2, 6)",
  "remoteAltitude": "@float(0, 10000, 2, 6)",
  "localPitchAngle": "@float(-90, 90, 2, 6)",
  "localCurrentPitchAngle": "@float(-90, 90, 2, 6)",
  "scatteringDeviceType": "@pick(['A', 'B', 'C'])",
  "waveType": "@integer(0, 2)",
  "channel": "@integer(1, 10)",
  "sendPower": "@float(0, 1000, 2, 6)",
  "freqType": "@integer(0, 2)",
  "freq": "@float(0, 1000, 2, 6)",
  "stopFreq": "@float(0, 1000, 2, 6)",
  "highFreq": "@float(0, 1000, 2, 6)",
  "stopHighFreq": "@float(0, 1000, 2, 6)",
  "freqInterval": "@integer(1, 100)",
  "jumpTableNum": "@integer(1, 10)",
  "iqCollectFlag": "@integer(0, 1)",
  "iqBusinessData": "@string('number', 16)",
  "iqCollectInterval": "@integer(1, 100)"
});

// 模拟任务定义接口的响应
const taskResponse = Mock.mock({
  "msg": "成功",
  "code": 200
});

// 修改导出方式
module.exports = [
  {
    url: '/task',
    method: 'post',
    response: (config) => {
      // 可以在这里添加对请求体的验证逻辑
      if (JSON.stringify(config.body) === JSON.stringify(taskRequestBody)) {
        return taskResponse;
      } else {
        return {
          "msg": "请求体格式错误",
          "code": 400
        };
      }
    }
  }
];